include CommonMakefile

PACKAGEDIR=edu/upenn/seas/peerreview
SRC=Common.scala Debug.scala
JARNAME=PRBS.jar
CP     = -classpath .
TESTERCP = -classpath .$(PATHSEP)transport/transport.jar$(PATHSEP)pr/pr.jar$(PATHSEP)smui/smui.jar
SCALAC:=$(SCALAC) -deprecation


# TO RUN WITH BOT (and display output lines with =)
APP = | tee output

all: test

transport:
	@echo "*************Making transport layer.***********"
	@make -C $@ stable
	@echo "*************Done Making transport layer.***********\n"

pr : 
	@echo "*************Making PR layer.***********"
	@make -C $@
	@echo "*************Done Making PR layer.***********\n"

smui: 
	@echo "*************Making SMUI layer.***********"
	@make -C $@
	@echo "*************Done Making SMUI layer.***********\n"
layers: transport pr smui

.classes: $(SRC) layers
	@echo "*************Building global classes.***********"
	$(SCALAC) $(CP) $(SRC) 
	$(SCALAC) $(CP)$(PATHSEP)pr/pr.jar$(PATHSEP)smui/smui.jar pr/PRCheating.scala
	@touch .classes 
#hack for now so no recompile each time; we make a flag file

compile: .classes #standard command - 'make compile'

#Had to stick PRCheating in here to get all dependencies right
#Tester.class: .classes Tester.scala
$(JARNAME): Tester.scala .classes
	@echo "*************Building Tester.***********"
	$(SCALAC) $(TESTERCP) Tester.scala 
	@echo "\n*************Building JAR File.***********"
	jar cfm $(JARNAME) lib/Manifest.txt *.class $(PACKAGEDIR)/*.class $(PACKAGEDIR)/pr/*.class
	@rm *.class

install: $(JARNAME)

test: install $(JARNAME)
	java -cp . -jar $(JARNAME) $(APP)

#clean, rebuild, upload
export: clean install
	lib/googlecode_upload.py -p scala-peer-review -s "Most recent build" -l "scala,penn,peer-review,battleship,Featured" $(JARNAME)

clean:
	@echo "**********Cleaning transport**********"
	@make -C transport clean
	@echo "**********Cleaning UISM**********"
	@make -C smui clean
	@echo "**********Cleaning PR**********"
	@make -C pr clean
	rm -rf *~ *.class output edu/ .classes $(JARNAME)

.PHONY: all clean test install compile export layers transport pr smui
